#include<bits/stdc++.h>
#define rep(l,r,i) for(int i=l;i<=r;i++) 
#define per(l,r,i) for(int i=l;i>=r;i--) 
#define pi pair<int,int> 
#define mk make_pair 
using namespace std;
#define int long long 
#define Maxn 5005 
int n,k,a[Maxn],b[Maxn],sum[Maxn],R[Maxn],f[2505][Maxn],maxn[Maxn];
int calc(int l,int r) {
    return sum[r]-sum[l-1];
}
void Main() {
    cin>>n>>k;
    rep(0,n+1,i)rep(0,Maxn-1,j)f[i][j] = 0;
    rep(0,Maxn-1,i)maxn[i] = 0;
    rep(1,n-1,i)cin>>a[i]; a[0] = a[n] = Maxn-1;
    rep(1,k,i)cin>>b[i],sum[i] = sum[i-1]+b[i];
    rep(1,n,i)R[i] = calc(max(1ll,k-n+i),min(k,i));
    rep(1,n,i) {
        rep(0,min(a[i-1],a[i]),j) {
            f[i][j] = (a[i-1]-j >= 0?maxn[a[i-1]-j]:0)+j*R[i];
        }
        rep(0,Maxn-1,j)maxn[j] = max((j > 0?maxn[j-1]:0),f[i][j]);
    } cout<<maxn[a[n-1]]<<"\n";
    return void();
}
signed main()
{
    freopen("festival2.in","r",stdin);
    freopen("festival.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int c,t; cin>>c>>t;
    while(t --)Main();
    return 0;
}